<body class="app" data-ad="true">
<?php $CDN= $this->CommonHelper()->imageDomain();?>
<section class="app-content">
	<section class="page page-index noline" data-plugin-type="info_front">

        <div class="top-bar">订单评分<a href="<?php echo $this->url('myorder', array('action'=>'index'));?>" class="btn-t-back"></a></div>
        <div class="af-sales-order bw os-info">
            <p class="af-l"><span class="fl">预定时间：<?php echo $this->escapeHtml($order['order_create_time']);?></span></p>
            <table class="o-info-list">
                <tbody>
                <?php foreach ($orderitems as $item) : ?>
                <tr>
                    <td class="o-01"><span><?php echo $this->escapeHtml($item['oi_name']);?></span></td>
                    <td class="o-02">¥ <?php echo $this->escapeHtml($item['oi_price']);?></td>
                    <td class="o-03 ">x<?php echo $this->escapeHtml($item['oi_amount']);?></td>
                </tr>
                <?php endforeach; ?>
                </tbody>

            </table>
        </div>
        <div class="info-list mt20 bw">
            <div class="shop-info">
                <span><img src="<?php echo $CDN.$this->escapeHtml($org['org_logo']);?>"></span><b><?php echo $this->escapeHtml($org['org_name']);?></b>
            </div>
            <h2 class="os-tit">服务评价</h2>
            <ul class="score-list">
                <li id="m_clear_score"><em>菜品卫生</em><span></span><span></span><span></span><span></span><span></span></li>
                <li id="m_taste_score"><em>菜品味道</em><span></span><span></span><span></span><span></span><span></span></li>
                <li id="m_speed_score"><em>送餐速度</em><span></span><span></span><span></span><span></span><span></span></li>
                <li id="m_service_score"><em>服务态度</em><span></span><span></span><span></span><span></span><span></span></li>
                <li id="m_total_score"><em>整体满意度</em><span></span><span></span><span></span><span></span><span></span></li>
            </ul>
        </div>

        <a class="btn-w btn-yel" href="javascript:submitOrderScore();">提交</a>
    <form id="orderScoreForm" action="/myorder/scoreSave" method='post'>    
        <input id="order_no" name="order_no" type="hidden" value="<?php echo $this->order['order_no'];?>">
        <input id="clear_score" name="clear_score" type="hidden" value="">
        <input id="taste_score" name="taste_score" type="hidden" value="">
        <input id="speed_score" name="speed_score" type="hidden" value="">
        <input id="service_score" name="service_score" type="hidden" value="">
        <input id="total_score" name="total_score" type="hidden" value="">
    </form>
	</section>

    <!-- 底部menu-->
    <?php echo $this->partial('public/menu.phtml'); ?>
</section>
<script src="/mobile/js/jquery-1.7.2.min.js?<?php echo $this->CommonHelper()->version();?>"></script>
<script type="text/javascript">

//下订单
function submitOrderScore(){

    var clear_score = $('#clear_score').val();
    if(clear_score == 0){
        alert("请先选择评分！");
        return false;
    }

    var taste_score = $('#taste_score').val();
    if(taste_score == 0){
    	alert("请先选择评分！");
        return false;
    }

    var speed_score = $('#speed_score').val();
    if(speed_score == 0){
    	alert("请先选择评分！");
        return false;
    }

    var service_score = $('#service_score').val();
    if(service_score == 0){
    	alert("请先选择评分！");
        return false;
    }

    var total_score = $('#total_score').val();
    if(total_score == 0){
    	alert("请先选择评分！");
        return false;
    }

    $("#orderScoreForm").submit();
}

$(function () {
    //星星效果
    $('.score-list li').each(function(){
        $(this).find('span').click(function(){
            var _idx = $(this).index();
            console.log('www'+_idx);
            console.log($(this).parent('li').attr('id').replace('m_',''));
            var id = $(this).parent('li').attr('id').replace('m_','');
            $("#"+id).val(_idx);
            $(this).parent('li').find('span:lt('+ _idx +')').addClass('on');
            $(this).parent('li').find('span:gt('+ (_idx-1) +')').removeClass('on');
        })
    })


    var maxstrlen = 50;
    var wck = $('.rel-line').find('i');
    $("#text-upload").keyup(function () {
        len = maxstrlen;
        var str = $(this).val();
        myLen = getStrleng(str);
        if (myLen > len * 2) {
            $(this).value = str.substring(0, i + 1);
        }
        else {
            wck.html(Math.floor((len * 2 - myLen) / 2));
        }
    });
    function getStrleng(str) {
        myLen = 0;
        i = 0;
        for (; (i < str.length) && (myLen <= maxstrlen * 2); i++) {
            if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 128)
                myLen++;
            else
                myLen += 2;
        }
        return myLen;
    }


});
</script>
